package com.xm.servlet.background.commodity;

import com.google.gson.Gson;
import com.xm.entity.CommodityParameter;
import com.xm.service.background.CommodityParameterService;
import lombok.SneakyThrows;

import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
 * 新增商品参数
 * @author 康文程
 * @date 2024-1-20 上午 09:58
 */
@WebServlet("/background/add/commodity/parameter")
public class AddCommodityParameterServlet extends HttpServlet {
    private final CommodityParameterService service = new CommodityParameterService();
    @SneakyThrows
    @Override
    protected void doPost(HttpServletRequest req, HttpServletResponse resp) {
        String commodityParameterJson = req.getParameter("commodityParameter");
        resp.getWriter().print(service.add(new Gson().fromJson(commodityParameterJson, CommodityParameter.class)));
    }
}
